/*
	TokenBasic.h

	define Marcos and classes of CToken

	@author Wolfhead
*/

#pragma once

#include "wfx.h"

// Let our Token be a tuple
#include "util/tuple.h"

MAKE_PTR(CToken);

// typedef Token_Type as int 
typedef int						Token_Type;

// define basic Token Types
// Marks of terminate token and non-terminate token
#define TERMINATE_TOKEN			(0x00010000)
#define NONTERMINATE_TOKEN		(0x00100000)
// -----------------------------------------
#define TOKEN_ERROR				(0x00000000)
#define TOKEN_EMPTY				(0x01010000)
#define TOKEN_EOF				(0x02010000)
// -----------------------------------------
#define TOKEN_START_EXTENSION	(0x01100000)
#define TOKEN_START				(0x02100000)
// -----------------------------------------
#define TOKEN_NUMBER			(0x03010000)
#define TOKEN_WORD				(0x04010000)
#define TOKEN_STRING			(0x05010000)
// -----------------------------------------



// Test if a token type is terminate type
#ifndef IS_TERMINATE_TOKEN
#define IS_TERMINATE_TOKEN(nTokenType)\
	((nTokenType & TERMINATE_TOKEN) ? true : false)
#endif

// define attribute _tag_Token_type
ATTRIBUTE(_tag_Token_Type, Token_Type);


class CToken: public tuple
{
public:
    CToken()
    {
		SetType(TOKEN_ERROR);
    }

    virtual ~CToken(void)
    {

    }

public:
    inline void SetType(Token_Type type)
    {
		this->set<_tag_Token_Type>(type);
    }

    inline Token_Type GetType()
    {
        return this->get<_tag_Token_Type>();
    }

};


